//
//  ZSGuidePageController.m
//  online
//
//  Created by  ysyy on 2018/8/2.
//  Copyright © 2018年  ysyy. All rights reserved.
//

#import "ZSGuidePageController.h"
#import "MainViewController.h"
#import "AppDelegate.h"
#import "LoginViewController.h"

@interface ZSGuidePageController ()

@end

@implementation ZSGuidePageController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.pagingEnabled = YES;
    
    NSInteger count = 4;
    for (int i = 0; i < count; i++) {
        UIImageView* imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"yindao%d", i + 1]];
        
        imageView.size = scrollView.size;
        imageView.x = i * scrollView.width;
        
        [scrollView addSubview:imageView];
        
        if (i == count - 1) {
            
            [self setupLastPageWithView:imageView];
        }
    }
    
    [scrollView setContentSize:CGSizeMake(count * scrollView.width, 0)];
    
    [self.view addSubview:scrollView];
    
    
}

- (void)setupLastPageWithView:(UIImageView*)imageView
{
    
    imageView.userInteractionEnabled = YES;
    
    UIButton* loginButton = [[UIButton alloc] init];
//    loginButton.backgroundColor = [UIColor redColor];
    [loginButton setImage:ImageNamed(@"4logo") forState:UIControlStateNormal];
    
    [imageView addSubview:loginButton];
    
    [loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(imageView);
        make.size.mas_equalTo(CGSizeMake(194 * SCREENH6, 88 * SCREENH6));
        make.bottom.equalTo(imageView).offset(-30 * SCREENH6);
    }];

    [loginButton addTarget:self action:@selector(loginBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
}




- (void)loginBtnClick:(UIButton*)button
{
//    [ZSWindowTool switchRootVc];
    MainViewController * navVC = [[MainViewController alloc] initWithRootViewController:[LoginViewController new]];
    
   [UIApplication sharedApplication].keyWindow.rootViewController = navVC;
}

@end
